#ifndef SNAKE_H
#define SNAKE_H

#include <QMainWindow>
#include<qpainter.h>
#include<QVector>
#include<qstring.h>

QT_BEGIN_NAMESPACE
namespace Ui { class snake; }
QT_END_NAMESPACE

class snake : public QMainWindow
{
    Q_OBJECT

public:
    explicit snake(QWidget* parent = 0);
    ~snake();
    void paintEvent(QPaintEvent* event);
    void InitSnake();//初始化蛇
    QRect CreateRect();
    void IsEat();
    void IsHit();

private slots:
    void Snake_update();//定义槽函数

private:
    Ui::snake* ui;
    QVector<QRect> vSnakeRect;//蛇
    QRect SnakeHead;//蛇头
    void keyPressEvent(QKeyEvent* key);
    QTimer* timer;//定时器
    bool blsRun;
    bool blsOver;
    QString sDisplay;
    int nDirection;//蛇的移动方向
    QRect food;
    int nScore;//得分
    QString scoreLabel;//显示“得分”
    int speed;//移速


};
#endif // SNAKE_H